package com.tacademy.android.lbs.location.model;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class Place {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)     
	private Key key;
	
	@Persistent
	private Date date;
	
	@Persistent
	private String placeName;
	
	@Persistent
	private double latitude;

	@Persistent
	private double longitude;
	
	@Persistent
	private String placeId;
	
	@Persistent
	private String user;
	
	@Persistent
	private int count;
	
	public void setKey(Key key) {
		this.key = key;
	}
	public Key getKey() {
		return key;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public String getPlaceName() {
		return placeName;
	}
	public void setPlaceName(String placeName) {
		this.placeName = placeName;
	}
	public double getLatitude() {
		return latitude;
	}
	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}
	public double getLongitude() {
		return longitude;
	}
	public void setLongitude(double longitude) {
		this.longitude = longitude;
	}
	public String getPlaceId() {
		return placeId;
	}
	public void setPlaceId(String id) {
		this.placeId = id;
	}
	public String getUser() {
		return user;
	}
	public void setUser(String user) {
		this.user = user;
	}
	public int getCount() {
		return count;
	}
	public void setCount(int count) {
		this.count = count;
	}
	public String toString() {
		StringBuilder builder = new StringBuilder(super.toString());
		builder.append("\ndate:").append(date);
		builder.append("\nplaceName:").append(placeName);
		builder.append("\nlatitude:").append(placeName);
		builder.append("\nlongitude:").append(longitude);
		builder.append("\nplaceId:").append(placeId);
		builder.append("\nuser:").append(user);
		
		return builder.toString();
	}
	public String xmlString() {
		StringBuilder xmlStrBuilder = new StringBuilder();
		xmlStrBuilder.append("<place>\n");
		xmlStrBuilder.append("\t<key>").append(key).append("</key>\n");
		xmlStrBuilder.append("\t<placeName>").append(placeName).append("</placeName>\n");
		xmlStrBuilder.append("\t<latitude>").append(latitude).append("</latitude>\n");
		xmlStrBuilder.append("\t<longitude>").append(longitude).append("</longitude>\n");
		xmlStrBuilder.append("\t<placeId>").append(placeId).append("</placeId>\n");
		xmlStrBuilder.append("\t<date>").append(date).append("</date>\n");
		xmlStrBuilder.append("\t<user>").append(user).append("</user>\n");
		xmlStrBuilder.append("\t<count>").append(count).append("</count>\n");
		xmlStrBuilder.append("</place>\n");
		return xmlStrBuilder.toString();
	}
}